/**
 * 是否登录
 */
const pathJoin = require('../common-api/data-path')
const { router, libQuery } = require('../../lib/route')
const RxfileWrite = require('rxfile-write')

libQuery((req, res, next, method) => {
  const cookies = req.cookies
  const user = cookies.user || ''
  // console.log('cookies=', cookies)
  if (!user) {
    res.send('0')
    return
  }
  const isloginPath = pathJoin('islogin/' + user)
  RxfileWrite.read(isloginPath).then(text => {
    console.log('success -> text=', text)
    res.send(text)
  }).catch(() => {
    res.send('0')
  })
}, '/islogin', 'text')

module.exports = router